//
//  LogicCalculatorViewController.m
//  LogicCalculator
//
//  Created by Francisco Gindre on 4/25/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "LogicCalculatorViewController.h"


@implementation LogicCalculatorViewController

@synthesize pButton;
@synthesize qButton;
@synthesize rButton;
@synthesize andButton;
@synthesize orButton;
@synthesize xorButton;
@synthesize notButton;
@synthesize thenButton;
@synthesize doubleThenButton;

@synthesize leftBracketButton;
@synthesize rightBracketButton;
@synthesize enterButton;
@synthesize clearButton;
@synthesize deleteButton;

@synthesize pSwitch;
@synthesize qSwitch;
@synthesize rSwitch;

@synthesize resultField;
@synthesize checkImage;

// other elements
@synthesize calculator;
@synthesize tickImage;
@synthesize errorImage;



	
-(IBAction)qButtonPressed:(id)sender{
	[[calculator getSentence]addObject:[calculator getQ]];
	

}
-(IBAction)pButtonPressed:(id)sender{
}
-(IBAction)rButtonPressed:(id)sender{
}

-(IBAction)andButtonPressed:(id)sender{}
-(IBAction)orButtonPressed:(id)sender{}
-(IBAction)xorButtonPressed:(id)sender{}
-(IBAction)notButtonPressed:(id)sender{}
-(IBAction)thenButtonPressed:(id)sender{}
-(IBAction)doubleThenButtonPressed:(id)sender{}

-(IBAction)leftBracketButtonPressed:(id)sender{}
-(IBAction)rightBracketButtonPressed:(id)sender{}
-(IBAction)enterButtonPressed:(id)sender{}
-(IBAction)clearButtonPressed:(id)sender{}
-(IBAction)deleteButtonPressed:(id)sender{}

-(IBAction)qSwitchChanged:(id)sender{}
-(IBAction)pSwitchChanged:(id)sender{}
-(IBAction)rSwitchChanged:(id)sender{}

- (void) refreshcheckImage{
	if ([calculator isSentenceBalanced:[calculator getSentence]]) {
		[checkImage setImage:tickImage];
		
	}else {
		[checkImage setImage:errorImage];
		
	}

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	// initialize image resources
	
	tickImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tick" ofType:@"png"]];
	errorImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"error" ofType:@"png"]];
	[checkImage setImage:tickImage];
	
	// initialize calculator
	calculator = [[LogicCalculator alloc]init];
	
	
	
}




// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}


- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
